package application.actions;

import io.IOClient;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JOptionPane;

import application.Launcher;

public class DisconnectAllAction extends AbstractAction{

	
	public void actionPerformed(ActionEvent e) {
		
		if(Launcher.getMainFrame().getConnectedClients().size() > 0)
		{
			
			int res = JOptionPane.showConfirmDialog(null, "Are you sure you want to break all connections?");
			if(res == JOptionPane.YES_OPTION)
			{
				for(IOClient c : Launcher.getMainFrame().getConnectedClients())
					Launcher.getMainFrame().removeConnection(c);
			}
		}
		else
		{
			JOptionPane.showMessageDialog(null, "There aren't any connected clients");
		}
	}
}
